copy of main branch (Sourcery refactored)#34
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
|
||
| # Set the title | ||
| plt.title("Quadratic Equation: y = {}x^2 + {}x + {}".format(a, b, c)) | ||
| plt.title(f"Quadratic Equation: y = {a}x^2 + {b}x + {c}") |
There was a problem hiding this comment.
Lines 137-137 refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
| """ | ||
| bmi = weight / (height ** 2) | ||
| return bmi | ||
| return weight / (height ** 2) |
There was a problem hiding this comment.
Function calculate_bmi refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| weight = float(input("Enter your weight in {}: ".format(weight_unit))) | ||
| weight = float(input(f"Enter your weight in {weight_unit}: ")) | ||
|
|
||
| height_unit = input("Enter height unit (feet or meters): ") | ||
| height = float(input("Enter your height in {}: ".format(height_unit))) | ||
| height = float(input(f"Enter your height in {height_unit}: ")) | ||
|
|
||
| # Convert weight to kg if entered in lbs | ||
| if weight_unit.lower() == "lbs": | ||
| weight = weight * 0.453592 | ||
| weight *= 0.453592 | ||
|
|
||
| # Convert height to meters if entered in feet | ||
| if height_unit.lower() == "feet": | ||
| height = height * 0.3048 | ||
| height *= 0.3048 |
There was a problem hiding this comment.
Function main refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting) - Replace assignment with augmented assignment [×2] (
aug-assign)
| if number % i == 0: | ||
| factors.append(i) | ||
| return factors | ||
| return [i for i in range(1, number + 1) if number % i == 0] |
There was a problem hiding this comment.
Function calculate_factors refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| for i in range(2, int(number ** 0.5) + 1): | ||
| if number % i == 0: | ||
| return False | ||
| return True | ||
| return all(number % i != 0 for i in range(2, int(number ** 0.5) + 1)) |
There was a problem hiding this comment.
Function is_prime refactored with the following changes:
- Use any() instead of for loop (
use-any) - Invert any/all to simplify comparisons (
invert-any-all)
| else: | ||
| pass | ||
|
|
There was a problem hiding this comment.
Lines 469-507 refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass) - Replace multiple comparisons of same variable with
inoperator (merge-comparisons) - Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| derivative_equation = sympy.diff(equation, x) | ||
| return derivative_equation | ||
| return sympy.diff(equation, x) |
There was a problem hiding this comment.
Function differentiate_equation refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| gamma = 1 / (1 - (velocity ** 2 / 299792458 ** 2)) # Lorentz factor | ||
| time_dilated = time * gamma | ||
| return time_dilated | ||
| return time * gamma |
There was a problem hiding this comment.
Function time_dilation refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| length_contracted = length / gamma | ||
| return length_contracted | ||
| return length / gamma |
There was a problem hiding this comment.
Function length_contraction refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| energy = mass * c ** 2 | ||
| return energy | ||
| return mass * c ** 2 |
There was a problem hiding this comment.
Function energy refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
|
Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information |
Pull Request #33 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
mainbranch, then run:Help us improve this pull request!
This change is